type(1)int
2025-02-04
Let’s take a look at the homework
import numpy as np
import os
def AP_check(folder):
AP_sweep_count = 0
for filename in os.listdir(folder):
if filename.endswith('.csv'):
with open(os.path.join(folder, filename), 'r') as file:
data = np.loadtxt(file, skiprows=1)
if any(data > 20):
AP_sweep_count += 1
print("AP found in " + filename)
else:
print('No AP in ' + filename)
return AP_sweep_count
file_path = 'data/sweeps_csv/'
sweep_count = AP_check(file_path)
print(sweep_count)The important question of what to do “if” something happens.
if something is True
somethingelse
something elsevalue = 3
1if value == 1:
print("the value is 2")
2elif value == 2:
print("the value is 2")
3elif value == 3:
4 print("the value is 3")
else:
print("the value is something else")value is 1
value is 2
value is 3
the value is 3
amplitude = 24
is_action_potential = "is AP" if amplitude > 0 else "no AP"
print(is_action_potential)is AP
everything_is_true = [True, True, True]
something_is_true = [True, False, False]
all(everything_is_true)
all(something_is_true)True
False
while something is TrueThere are useful resources regarding errors